package com.phuc.game.tankshooter.sprite;

import org.anddev.andengine.entity.modifier.PathModifier.Path;
import org.anddev.andengine.entity.scene.Scene;

import com.phuc.game.tankshooter.engine.GamePlay;
import com.phuc.game.tankshooter.engine.MovingPathFactory;

import static com.phuc.game.tankshooter.engine.MovingPathFactory.*;

public class EnemyTankTigerGreen extends EnemyObjectSprite {

	private static final int SIZE_TILE_W = 80;
	private static final int SIZE_TILE_H = 80;
	
	public EnemyTankTigerGreen(Scene scene, Path [] pathParams) {
		super(GamePlay.textureEnemyTankTigerGreen.getFaceTiledTextureRegion(),
				scene, SIZE_TILE_W, SIZE_TILE_H);
		hp = 130;
		hpLeft = 130;
		speed = 13;
		size = SIZE_TILE_W / 2;
		
		if (pathParams == null) {
			// Create path for tank
			Path[] path = MovingPathFactory.createRandomPath(
					PATH_TYPE_ZIGZAG_STANDARD_2_TOP_BOTTOM
					);
			this.setPath(path);
		} else {
			this.setPath(pathParams);
		}
		this.moveOnNextPath();
	}

	public int getTankSizeW() {
		return SIZE_TILE_W;
	}
	
	public int getTankSizeH() {
		return SIZE_TILE_H;
	}

	public void moveOnNextPath() {
		// Animation
		int startFrame = 0;
		int endFrame = 3;
		int frameDuration = 100;
		this.animate(new long[] { frameDuration, frameDuration, frameDuration,
				frameDuration }, startFrame, endFrame, true);
		super.moveOnNextPath();
	}
	
	@Override
	public void attacked(int damage) {
		super.attacked(damage);
		if (hpLeft <= 0) {
			GamePlay.tankTigerKill++;
		}
	}
}
